#pragma once
/* Constant buffer interface. Used only in DX10 and later dx versions.
 */
#include "Includes.h"
#include "Engine/RenderGlobals.h"

struct TConstantVariableData
{
    size_t Offset;//offset from buffer data ptr
    std::string sName;
};

struct TResourceData
{
    //mUInt uSRVIndex;
    std::string sName;
};

struct TCBufferData
{
    mVoid *pData;
    size_t Size;
    mBool  bChanged;
    std::vector< TConstantVariableData > CVariables;
};

class CConstantStorageDX10
{
protected:
    /* Constant buffers */
    TCBufferData              *m_pBuffersData;
    ID3D10Buffer             **m_ppBuffers;
    /* Resources */
    TResourceData             *m_pResData;
    ID3D10ShaderResourceView **m_ppSRV;
    mUInt                      m_uNumResources;

    CConstantStorageDX10               ( );
    ~CConstantStorageDX10              ( );
    mVoid Init                         ( ID3D10Blob *a_pShaderCode );
    /* Adding constant into cbuffer */
    mBool SendConstantValue            ( const std::string &a_sConstName, mVoid *a_pValue, size_t a_ValueSize, TChangeFreq a_ChangeFreq );
    /* Adding resource. To send SRVs to shader, call d3ddevice10->[V/G/P]SSetShaderResourses in your shader class. */
    mBool AddResource                  ( const std::string &a_sConstName, ID3D10ShaderResourceView *a_pSRV );
    /* Loading cbuffer into vram */
    mVoid UpdateConstantValues         ( );
};